package com.black.play;

import com.black.play.component.SudokuWindow;
import com.black.play.entity.SudokuCreator;
import com.black.play.entity.SudokuGenerator;
import com.black.play.entity.SudokuBoard;
import com.black.play.entity.SudokuSolutions;

public class App
{
    public static void main(String[] args)
    {
        SudokuWindow instance = SudokuWindow.getInstance();
        instance.setVisible(true);
    }

    public static void testCreate()
    {
        SudokuSolutions creatorSolutions = new SudokuSolutions();
        SudokuSolutions generatorSolutions = new SudokuSolutions();
        long creatorStart = System.currentTimeMillis();
        for (int i = 0; i < 300; i++)
        {
            System.out.println("Creator 第" + (i + 1) + "个完整数独：");
            SudokuBoard board = SudokuCreator.generateCompleteSudoku();
            creatorSolutions.addSolution(board);
            board.printBoard();
        }
        long creatorEnd = System.currentTimeMillis();
        long generatorStart = System.currentTimeMillis();
        for (int i = 0; i < 300; i++)
        {
            System.out.println("Generator 第" + (i + 1) + "个完整数独：");
            SudokuBoard board = SudokuGenerator.generateCompleteSudoku();
            generatorSolutions.addSolution(board);
            board.printBoard();
        }
        long generatorEnd = System.currentTimeMillis();
        long creatorRmStart = System.currentTimeMillis();
        creatorSolutions.getSolutions().forEach(solution ->
        {
            SudokuCreator.removeNumbersFromBoard(solution.getBoard(), 40);
            solution.printBoard();
        });
        long creatorRmEnd = System.currentTimeMillis();
        long generatorRmStart = System.currentTimeMillis();
        generatorSolutions.getSolutions().forEach(solution ->
        {
            SudokuGenerator.removeNumbersFromBoard(solution.getBoard(), 40);
            solution.printBoard();
        });
        long generatorRmEnd = System.currentTimeMillis();
        System.out.println("Creator 生成耗时：" + (creatorEnd - creatorStart) + "ms");
        System.out.println("Creator 移除耗时：" + (creatorRmEnd - creatorRmStart) + "ms");
        System.out.println("Generator 生成耗时：" + (generatorEnd - generatorStart) + "ms");
        System.out.println("Generator 移除耗时：" + (generatorRmEnd - generatorRmStart) + "ms");
    }
}